package com.dylan.equipment.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dylan.equipment.dao.IDepartmentDao;
import com.dylan.equipment.entity.Department;
import com.dylan.equipment.entity.PageBean;
import com.dylan.equipment.utils.StringUtil;

@Service
public class DepartmentService {
	
	@Resource
	private IDepartmentDao departmentDao;
	
	public List<Department> find(PageBean page, Department s_department) {
		Map<String, Object> params = new HashMap<>();
		if(page!=null){
			params.put("start", page.getStart());
			params.put("pageSize", page.getPageSize());
		}
		
		if(s_department!=null){
			if(StringUtil.isNotEmpty(s_department.getDeptName())){
				params.put("deptName", s_department.getDeptName());
			}
		}
		List<Department> departmentList = departmentDao.find(params);
		return departmentList;
	}
	public int count(Department s_department){
		return departmentDao.count(s_department);
	}

	public void add(Department department){
		departmentDao.add(department);
	}

	public void update(Department department){
		departmentDao.update(department);
	}

	public void delete(int id){
		departmentDao.delete(id);
	}

	public Department loadById(int id){
		return departmentDao.loadById(id);
	}
}
